package com.xqls.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xqls.bean.PermissionBean;
import com.xqls.biz.PermissionBiz;
import com.xqls.service.PermissionService;
import com.xqls.util.ObjectUtil;

@Service
public class PermissionBizImpl implements PermissionBiz {

	@Autowired private PermissionService permissionService;

	@SuppressWarnings("unchecked")
	@Override
	public List<PermissionBean> getList() {
		List<PermissionBean> permissionList=null;
		try {
			permissionList=ObjectUtil.transferList(this.permissionService.getList(), PermissionBean.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return permissionList;
	}
	@Override
	public List<Map<String, Object>> getPermissionList() {
		List<Map<String, Object>> permissionList=null;
		try {
			permissionList=this.permissionService.getPermissionList();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return permissionList;
	}
	
	@Override
	public List<Map<String, Object>> getPermissionTreeList() {
		List<Map<String, Object>> permissionList=null;
		try {
			permissionList=this.permissionService.getPermissionTreeList();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return permissionList;
	}

	@Override
	public List<Map<String, Object>> getPermissionTreeListByRoleId(String roleId) {
		List<Map<String, Object>> mapList=null;
		Map<String, Object> map=new HashMap<String, Object>();
		try {
			map.put("roleId", roleId);
			mapList=this.permissionService.getPermissionTreeListByMap(map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapList;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<PermissionBean> getListByRoleId(String roleId) {
		List<PermissionBean> permissionList=null;
		Map<String, Object> map=new HashMap<String, Object>();
		try {
			map.put("roleId", roleId);
			permissionList=ObjectUtil.transferList(this.permissionService.getListByMap(map), PermissionBean.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return permissionList;
	}

	
}
